package cn.sylinx.hbatis.ext.parse;

import java.util.HashMap;
import java.util.Map;

import cn.sylinx.hbatis.kit.StrKit;

/**
 * 参数构建器
 * 
 * @author han
 *
 */
public class ParaMapBuilder {

	private Map<String, Object> map = new HashMap<>();

	public ParaMapBuilder put(String key, Object value) {
		if(value != null) {
			map.put(key, value);
		}
		return this;
	}

	public ParaMapBuilder like(String key, String value) {
		if (StrKit.isNotBlank(value)) {
			map.put(key, "%" + value + "%");
		}
		return this;
	}

	public ParaMapBuilder likeLeft(String key, String value) {
		if (StrKit.isNotBlank(value)) {
			map.put(key, "%" + value);
		}
		return this;
	}

	public ParaMapBuilder likeRight(String key, String value) {
		if (StrKit.isNotBlank(value)) {
			map.put(key, value + "%");
		}
		return this;
	}

	public Map<String, Object> build() {
		return map;
	}

}
